package com.suneast.suneaststore.modules.personal.order.adapter;

import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.suneast.suneaststore.R;
import com.suneast.suneaststore.bean.personal.order.FastOrderDetailBean;
import com.suneast.suneaststore.modules.common.Flag;

public class FastOrderAdapter extends BaseQuickAdapter<FastOrderDetailBean.GalleryBean,
        BaseViewHolder> {

    private @Flag.FastOrderState
    int state;

    public void setState(@Flag.FastOrderState int state) {
        this.state = state;
    }

    public @Flag.FastOrderState
    int getState() {
        return state;
    }

    public FastOrderAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, FastOrderDetailBean.GalleryBean item) {
        Glide.with(helper.itemView.getContext()).load(item.getBill())
                .into((ImageView) helper.getView(R.id.img_order));
        switch (state) {
            case Flag.FastOrderState.MERCHANT_CHECKING: {//只显示用户自己上传的图片
                helper.getView(R.id.et_explain).setVisibility(View.GONE);
                helper.getView(R.id.img_reply).setVisibility(View.GONE);
                helper.getView(R.id.tv_add_reply_img).setVisibility(View.GONE);
            }
            break;
            case Flag.FastOrderState.CUSTOMER_COMMITTED: {//显示 用户上传的图片 定价说明回复编辑框 上传图片的按钮
                helper.getView(R.id.et_explain).setVisibility(View.VISIBLE);
                helper.getView(R.id.img_reply).setVisibility(View.VISIBLE);
                helper.getView(R.id.tv_add_reply_img).setVisibility(View.VISIBLE);
                helper.addOnClickListener(R.id.tv_add_reply_img);
            }
            break;
            default: {
                EditText et = helper.getView(R.id.et_explain);
                et.setVisibility(View.VISIBLE);
                et.setText(item.getText());
                et.setFocusable(false);
                ImageView replyImg = helper.getView(R.id.img_reply);
                replyImg.setVisibility(View.VISIBLE);
                Glide.with(helper.itemView.getContext()).load(item.getExplain()).into(replyImg);
                helper.getView(R.id.tv_add_reply_img).setVisibility(View.GONE);
            }
            break;
        }
    }
}
